﻿Public Class Form2

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click

        Dim Command As String
        Command = ("netsh wlan set hostednetwork mode=allow ssid=" + TextBox2.Text + " key=" + TextBox3.Text)

        Dim start As New System.IO.StreamWriter("C:\WiFi Share™\Config\start.bat")
        start.WriteLine(Command)
        start.Close()

        MessageBox.Show("Settings Created. To go online, please click Start")
    End Sub

    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
        Form1.Show()
        Me.Hide()
    End Sub

    Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
        Form3.Show()
        Me.Hide()
    End Sub

    Private Sub Form_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If MsgBox("Are you sure you want to quit? All connections will be terminated.", MsgBoxStyle.Exclamation + MsgBoxStyle.OkCancel, "Warning") = vbOK Then
            Dim Command As String
            Command = "netsh wlan stop hostednetwork"
            Shell("cmd /c" & Command, AppWinStyle.Hide, True)
            End
        Else
            e.Cancel = True
            Exit Sub
        End If
    End Sub
End Class